package com.ysm.smfu.utils;

import android.content.Context;
import android.widget.Toast;

import com.ysm.smfu.R;

public class ToastUtils {


    private static Toast toast;

    /**
     * 静态toast
     *
     * @param context
     * @param text
     */
    public static void showToast(Context context, String text) {
        // toast消失了  toast 会自动为null
        if (toast == null) {// 消失了
            toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
        }

        toast.setText(text);
        toast.show();
    }


    public static void showToast(String text) {
        showToast(UIUtils.getContext(), text);
    }

    public static void cancelToast() {
        if (toast != null)
            toast.cancel();
    }

    public static void showErrToast() {
        showToast(UIUtils.getContext().getResources().getString(R.string.netError));
    }
}
